F week 16 FabAcademy 2016

week sixteen

The assignment for this week is to write an application that interfaces with an input &/or output device that I made,


What i am going to do :

  • Interfaces the Bluetooth module with mobile and computer
  • program the microcontroller to proses data from IR sensors
  • write an application for mobile to process data (the direction of motion of the finger ) receiving via Bluetooth

Which Protocol?

First I Studied about different network protocols like WIFI/WIMAX Protocols,Bluetooth protocol,TCP/IP model etc. finally i decided to use Bluetooth protocol v2.0. I choose HC-05 Bluetooth Module for this, it is a commonly used bluetooth module .


Specifications :-

  • Bluetooth protocol v2.0
  • Range 10 meters
  • Frequency: 2.4 Ghz ISM
  • Frequency: 2.4 Ghz ISM
  • Modulation: GFSK
  • Transmit power: 4dBm
  • Sensitivity: 84dBm
  • Rate: 2.1Mbps(Max) /160kbps(Async); 1Mbps(Sync)
  • Authentication & Encryption
  • Power Supply: +3.3 VDC 50mA
  • Operating Temperate: -20C to  +55 C
  • Dimensions: 26.9 mm x 13 mm x 2.2 mm


Modes of operation :-

        This have two modes: master and slave. You can set the module mode (master or slave) of the device by AT commands

  • MCU to MCU communication

    In this communication two MCUs communicate with each other. One MCU connects to Bluetooth master device and other one connects to slave device. Their connection can be built once the pair is established.




  • MCU to PC/Smart Phone Communication

    When MCU has Bluetooth salve module, it can communicate with Bluetooth adapter of computers and smart phones. Then there is a virtual communicable serial port line between MCU and computer or smart phone. Driver is not required when using the module with PC or Smart phone.







  • MCU to Other Slave device interfacing

    The other bluetooth devices in the market mostly are salve devices, such as Bluetooth printer, Bluetooth GPS. So, we can use master module to make pair and communicate with them.

Source :http://www.sunrom.com/p/serial-bluetooth-module





Choosing an Input Device


In this week I am going to use two IR transceiver because in my final project I am using IR LEDs to detecting motion of finger , so this is an important part of my final project.

The IR transmitter LED transmits continuous IR rays , when obstacles come near to IR transmitter LED IR rays reflected back . Due to this reflection, the amount of IR rays received by an IR receiver LED is increased . An IR receiver LED output terminal varies depending upon its amount of receiving of IR rays


For this I design a board with two IR transceiver and an ATtiny44 for processing the values from IR receivers ( show the schismatic and board design in my electronics design week / input device week )






Obtaining readings from the sensors

Here I am using two IR transceivers used for the movement detection .For Obtaining maximum and minimum readings from the sensors, connect the board to my computer using FTDI cable. Then continuously read IR receiver value using "analogRead" command in Arduino and use serial monitor to show the range of values



Using this program I got the maximum value from the sensor "900" ( when the finger very close to the sensor ) and minimum value "0" ( finger away from the sensor )




Programing the board


Then make a program for the finger movement detection . Here I using two IR sensors modules (sensor 1 and sensor 2) , if the finger is first above the sensor 1 input value to microcontroller I/O port of sensor one is 900 and sensor two is 0 , this time sent a value (1 or move left or play) via Bluetooth vice versa sensor two is 900 and sensor one is 0, this time another sent a value (0 or move right or pause )



Download the program












Build application with app inventor

I desired to build an android application for pause and play control using app inventor

What is MIT App Inventor?
MIT App Inventor is an innovative beginner's introduction to programming and app creation that transforms the complex language of text-based coding into visual, drag-and-drop building blocks. The simple graphical interface grants even an inexperienced novice the ability to create a basic, fully functional app within an hour or less.


Then I start to write program when the value receiving trough Bluetooth is "0" then start the video player or receiving trough Bluetooth is "1" then stop the video player .show below my code

Code:


Application user interface:



Application user interface on mobile :



I pulished my app in MIT App Inventor Gallery ai2.appinventor.mit.edu/?galleryId=5127150418264064 you will get both source code and apk file from that link

View the application
Download .apk File



The result













Build application with Python

Over the last few months, I have learned how to program with Python. In this projects that I am working on python for collecting data through Bluetooth and view the collected data on computer's display

problem : I start to interface with my computer But I cant collect the sending data's from my board in to serial monitor. This proble i solve by Creating a bluetooth serial port





Creating a bluetooth serial port on ubuntu

sudo hcitool scan
Scanning ...
00:02:C7:7D:F5:17 BlueGPS 7DF517
sudo rfcomm bind /dev/rfcomm0 00:02:C7:7D:F5:17 1
ls -l /dev/rfcomm0



After some searching I found pySerial. pySerial is an elegant piece of software that allows Python to send and receive data much like the Serial Monitor does

pySerial is available to download at https://pypi.python.org/pypi/pyserial

After download I install pySerial

sudo python setup.py install


To make sure that everything installed correctly open up Idle and type in 'Import Serial'. If no errors appears then everything is good to go

You can check the available ports with the line

ls /dev/tty.*


Next, in Idle I create a new window and write a program to read data from Bluetooth

from time import sleep
import serial
ser = serial.Serial('/dev/rfcomm0', 9600)

while True:
    print ser.readline()     # Read the newest data from Bluetooth
    sleep(.1)                         # Delay for one tenth of a second